package com.longge;

/**
 * @创建人 xinglongge
 * @创建时间 2021/11/24
 * @描述
 */
public class HasCycle {


    public boolean hasCycle(ListNode head) {
        ListNode slow = head, fast = head;
        while (fast!=null&&fast.next!=null){
            slow=slow.next;
            fast=fast.next.next;
            if (slow==fast) return true;
        }
        return false;
    }

}
